package com.taotao.health.controller;


import com.taotao.common.core.domain.Result;
import com.taotao.health.domain.vo.DoctorCreationsVO;
import com.taotao.health.service.CreateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("create")
public class CreateController {

    @Autowired
    private CreateService createService;
    /**
     *  对文章进行添加
     * @param doctorCreationsVO
     * @return
     */
    @RequestMapping("increaseArticle")
    public Result increaseArticle(@RequestBody DoctorCreationsVO doctorCreationsVO){
        return createService.increaseArticle(doctorCreationsVO);
    }
    /**
     *  查询医生个人草稿
     * @return
     */
    @PostMapping("selectDoctorDraft")
    public List<DoctorCreationsVO> selectDoctorDraft(){
        List<DoctorCreationsVO> doctorCreationsVOS = createService.selectDoctorDraft();
        return doctorCreationsVOS;
    }
    /**
     * 根据id修改
     * @param doctorCreationsVO
     * @return
     */
    @RequestMapping("updateArticleById")
    public Result updateArticleById(@RequestBody  DoctorCreationsVO doctorCreationsVO){
        return createService.updateArticleById(doctorCreationsVO);
    }
    /**
     * 根据id删除草稿
     * @param creationId
     * @return
     */
    @RequestMapping("deleteArticleById")
    public Result deleteArticleById(Integer creationId){
        return createService.deleteArticleById(creationId);
    }
    /**
     * 查询医生发布的文章
     * @return
     */
    @GetMapping("selectDoctorArticle")
    public List<DoctorCreationsVO> selectDoctorArticle(){
        List<DoctorCreationsVO> doctorCreationsVOS = createService.selectDoctorArticle();
        return doctorCreationsVOS;
    }
    /**
     * 根据id查询文章详情
     * @param creationId
     * @return
     */
    @PostMapping("selectArticleById")
    public List<DoctorCreationsVO> selectArticleById(Integer creationId){
        List<DoctorCreationsVO> doctorCreationsVOS = createService.selectArticleById(creationId);
        return doctorCreationsVOS;
    }
    /**
     * 查看所有列表
     * @return
     */
    @RequestMapping("selectDoctorPatient")
    public Result selectDoctorPatient(DoctorCreationsVO doctorCreationsVO){
        List<DoctorCreationsVO> all = createService.All(doctorCreationsVO);
        return Result.success(all);
    }
}
